package com.yantong.mapper;

import com.yantong.pojo.OrderSplitInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface OrderSplitInfoMapper {
	/**
	 * delete by primary key
	 *
	 * @param id primaryKey
	 * @return deleteCount
	 */
	int deleteByPrimaryKey(Long id);

	/**
	 * insert record to table
	 *
	 * @param record the record
	 * @return insert count
	 */
	int insert(OrderSplitInfo record);

	/**
	 * insert record to table selective
	 *
	 * @param record the record
	 * @return insert count
	 */
	int insertSelective(OrderSplitInfo record);

	/**
	 * select by primary key
	 *
	 * @param id primary key
	 * @return object by primary key
	 */
	OrderSplitInfo selectByPrimaryKey(Long id);

	/**
	 * update record selective
	 *
	 * @param record the updated record
	 * @return update count
	 */
	int updateByPrimaryKeySelective(OrderSplitInfo record);

	/**
	 * update record
	 *
	 * @param record the updated record
	 * @return update count
	 */
	int updateByPrimaryKey(OrderSplitInfo record);

	/**
	 * 根据订单id修改信息
	 *
	 * @param transactionNo 分账id
	 * @param outTradeNo    订单id
	 * @return int
	 * @author liaozhaogui
	 * @date 2021/8/12 10:17
	 */
	int updateByOutTradeNo(@Param("transactionNo") String transactionNo, @Param("outTradeNo") String outTradeNo);

	int updateByOutTradeNoReturn(@Param("outTradeNo") String outTradeNo, @Param("returnCode") String returnCode, @Param("returnMsg") String returnMsg);

	int updateYfzServiceChargeByOrderIdAndYfzServiceChargeFlag(@Param("updatedYfzServiceCharge") BigDecimal updatedYfzServiceCharge, @Param("outTradeNo") String outTradeNo,
                                                               @Param("yfzServiceChargeFlag") Integer yfzServiceChargeFlag);

	/**
	 * 批量新增
	 *
	 * @param list 集合参数
	 * @return int
	 * @author liaozhaogui
	 * @date 2021/8/12 10:17
	 */
	int insertList(@Param("list") List<OrderSplitInfo> list);

	OrderSplitInfo selectByRefIdAndOrderIdAndStatus(@Param("refId") Long refId, @Param("orderId") Long orderId, @Param("status") Integer status, @Param("payMid") Long payMid, @Param("type") Integer type);

	OrderSplitInfo selectByOrderProductIdAndOrderIdAndStatus(@Param("orderProductId") Long orderProductId, @Param("orderId") Long orderId, @Param("status") Integer status, @Param("type") Integer type);

	BigDecimal selectByStatusAndTypeAndSplitTypeAndTeamId(@Param("status") Integer status, @Param("type") Integer type, @Param("splitType") Integer splitType, @Param("teamId") Long teamId);

	int totalByParams(Map<String, Object> params);

	List<OrderSplitInfo> listByParams(Map<String, Object> params, RowBounds rowBounds);

	List<OrderSplitInfo> selectByOutTradeNo(@Param("outTradeNo") String outTradeNo);


}